<div class="content_filtro">
    <div class="filtro">
        <form id="form_filtro" method="post" action="">
            <i>Pesquisar</i>
            
            <input type="text" id="dtfiltro" name="dtfiltro" class="data" placeholder="Data" value="<?php echo $this->dtfiltro?>" />
            &nbsp;
            
            <?php
            /*
                $query = 'SELECT SQL_CACHE USU_ID,USU_NOME FROM USUARIOS WHERE USU_STA = 1 ORDER BY USU_NOME ASC';
                $f_cur = $this->db->fetchAll($query);

                $html = '<select id="cbfiltro" name="cbfiltro" class="chosen-select" >';
                $html .= '<option value="">Todos usuários</option>';
                foreach($f_cur as $r){   
                    $select = $this->cbfiltro == $r['USU_ID'] ? 'selected':''; 
                    $html .= '<option '.$select.' value="'.$r['USU_ID'].'">'.$r['USU_NOME'].'</option>'; 
                }
                $html .= '</select>';
                echo $html;
            */   
            ?>
            
            <input type="submit" value="buscar" name="buscar" class="btn-pdr">
            
        </form>
    </div>
    <?php if($this->per_add){?>
    <div class="content-btn">
        <span>Nova</span><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit','id'=>'')); ?>">+</a>
    </div>
    <?php } ?>
</div>

<br><a href="<?php echo $this->urlbase.'/public/upload/modelo_importacao_alunos.xls'; ?>" target="_blank">Modelo Arquivo de Importação</a>
<br><br>
<div class="content-list">
    
    <h2><?php echo $this->titulo;?></h2>
    
    <table id="tlist">
        <thead>
            <tr>
                <th>Instituição de Ensino</th>
                <th>Ano</th>
                <th>Semestre</th>
                <th>Chamada</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
            
            // permite excluir se não tiver aprovações
            $aprovados = FALSE;           
            $query = 'SELECT SQL_CACHE APV_ID FROM APROVACAO WHERE LAP_ID = '.$row['LAP_ID'];
            $row_lap = $this->db->fetchRow($query);
            if($row_lap['APV_ID'] > 0) {
                $aprovados = TRUE;
            }
            ?>
                <tr>
                    <td><?php echo $row['FAC_NOM']; ?></td>
                    <td><?php echo $row['LAP_ANO']; ?></td> 
                    <td><?php echo $row['LAP_SEM']; ?></td>
                    <td><?php echo $row['LAP_CHM']; ?></td>
                    <td class="bc">
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['LAP_ID'])); ?>">Editar</a><?php }?>
                        <?php if($this->per_del && ($row['LAP_STA'] < 2 || $aprovados == FALSE)){?><a class="btn-pdr" href="javascript:void(0);" onclick="list_delete('<?php echo $this->controller; ?>', <?php echo $row['LAP_ID'] ?>, $(this));">Deletar</a><?php }  ?>
                        <?php if($aprovados){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'aprovados', 'id' => $row['LAP_ID'])); ?>">Aprovados</a><?php } ?>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
<script>dataPicker($('#dtfiltro'));</script>